package com.selebash.ast;

import com.selebash.exception.SelebashException;
import com.selebash.features.FeatureHolder;
import com.selebash.runtime.ExecutionContext;
import com.selebash.scripts.Script;
import java.util.ArrayList;
import java.util.List;

/**
 * @author sad
 */
public abstract class AbstractAst {

    private int start;
    private int end;
    private final List<AbstractAst> nested = new ArrayList<>();
    protected FeatureHolder featureHolder;
    private Script document;

    public Script getDocument() {
        return document;
    }

    public void setDocument(Script document) {
        this.document = document;
    }

    public FeatureHolder getFeatureHolder() {
        return featureHolder;
    }

    public void setFeatureHolder(FeatureHolder featureHolder) {
        this.featureHolder = featureHolder;
    }

    public List<AbstractAst> getNested() {
        return nested;
    }

    public void addNestedAsts(List<AbstractAst> nodes) {
        for (AbstractAst node : nodes) {
            nested.add(node);
        }
    }

    public void addNestedAst(AbstractAst node) {
        nested.add(node);
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public int getEnd() {
        return end;
    }

    public void setEnd(int end) {
        this.end = end;
    }

    public void process(ExecutionContext executionContext) {
        throw new SelebashException(getClass().getSimpleName() + " process() is not implemented");
    }

}
